$def with (page)

$ _t = i18n.get_namespace('/type/edition')
$ _ = i18n.get_namespace('/mode/view')

$ s = "other_titles", "translated_titles", "genres", "first_publish_date", "subject_places", "original_languages", "dewey_number", "lc_classifications", "subjects", "subject_times", "excerpts"
$ subjects = ["subjects"]

$for name in s:
    $if page[name]:
        <div class="section">
        <table class="meta">
        <tbody>
            <tr><td class="descrip"><span class="title">$_t[name]</span></td>
            $if name == "other_titles":
                <td><span class="object">$:'; '.join(thingrepr(i) for i in page[name])</span></td></tr>
            $elif name == "translated_titles":
                $for t in page[name]: <td class="tag"><span class="object"><i>$t.language.name -</i> $t.text;</span></td></tr>
            $elif name == "subjects":
                <td><span class="object">
                $for name in subjects:
                    $for subject in page[name]:
                        <a href="/search?ftokens=$:utf8(facet_token('subjects', subject.strip()))">$:utf8(thingrepr(subject)).replace(' -- ', '/')</a>,
                </span></td></tr>
            $else:
                <td><span class="object">$:thingrepr(page[name])</span></td></tr>
        </tbody>
        </table>
        </div>

$ cur_locale = i18n.get_locale()
$ this_lang = False
$ simple = False
$ wikipedia = []
$ links = page.links

$if links:
    $for link in links:
        $ wiki_find = link.url.find('.wikipedia.org/')
        $ lang = link.url[7:wiki_find]
        $if not lang.replace('-', '').isalpha():
            $continue
        $ link['lang'] = lang
        $if lang == cur_locale:
            $ this_lang = link
        $if lang == 'simple':
            $ simple = link
        $ wikipedia.append(link)
    $if this_lang or len(wikipedia):
        <div class="section">
        <span class="title">$_t['wikipedia']:</span>
        $if this_lang:
            <span class="tag">$this_lang.lang: <a href="$this_lang.url">$(this_lang.title or this_lang.url)</a></span>
        $else:
            <span class="tag">No link to Wikipedia in your language</span>
            $if simple:
                <span class="tag">
                Simple English: <a href="$simple.url">$(simple.title or simple.url)</a>
                </span>
        $if len(wikipedia):
            <span class="tag"><a href="javascript:;" class="slide-toggle"
                aria-haspopup="true" aria-controls="full_list">Other languages</a></span>
            <div style="display: none" id="full_list"><span class="tag">
            $for link in wikipedia:
                $link.lang: <a href="$link.url">$(link.title or link.url)</a>&nbsp;
            </span></div>
        </div>
    $ links = [l for l in links if 'lang' not in l]
    $if links:
        <div class="section"><span class="title">$_t['links']:</span>
        <span class="tag">
            $for link in links: <a href="$link.url">$(link.title or link.url)</a><br />
        </span></div>
